/*
 * Copyright (C) 2017 Baidu, Inc. All Rights Reserved.
 */
package com.zhyl.zhyl_detect_demo.utils;

import java.util.Timer;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolManager {

    static Timer timerFocus = null;

    /*
     * 对焦频率
     */
    static final long cameraScanInterval = 2000;

    /*
     * 线程池大小
     */
    private static int poolCount = Runtime.getRuntime().availableProcessors();

    private static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(poolCount);

    private static ExecutorService singleThreadPool = Executors.newSingleThreadExecutor();

    /**
     * 给线程池添加任务
     *
     * @param runnable 任务
     */
    public static void execute(Runnable runnable) {
        fixedThreadPool.execute(runnable);
    }

    /**
     * 单独线程任务
     *
     * @param runnable 任务
     */
    public static void executeSingle(Runnable runnable) {
        singleThreadPool.execute(runnable);
    }


}
